package com.zhijian.medical.service.impl;

import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.io.IoUtil;
import cn.hutool.poi.excel.ExcelReader;
import cn.hutool.poi.excel.ExcelUtil;
import cn.hutool.poi.excel.ExcelWriter;
import com.google.common.collect.Lists;
import com.zhijian.medical.dao.local.ExamWarehouseMapper;
import com.zhijian.medical.entity.dto.ExamWarehouseImportDto;
import com.zhijian.medical.entity.po.ExamAnswer;
import com.zhijian.medical.entity.po.ExamQuestion;
import com.zhijian.medical.entity.po.ExamWarehouse;
import com.zhijian.medical.entity.vo.request.ExamAnswerSearchVo;
import com.zhijian.medical.entity.vo.request.ExamQuestionSearchVo;
import com.zhijian.medical.entity.vo.request.ExamWarehouseSearchVo;
import com.zhijian.medical.entity.vo.response.ExamAnswerVo;
import com.zhijian.medical.entity.vo.response.ExamQuestionVo;
import com.zhijian.medical.entity.vo.response.ExamWarehouseVo;
import com.zhijian.medical.enums.QuestionTypeEnum;
import com.zhijian.medical.enums.ResponseCodeEnum;
import com.zhijian.medical.exception.BusinessException;
import com.zhijian.medical.service.ExamAnswerService;
import com.zhijian.medical.service.ExamQuestionService;
import com.zhijian.medical.service.ExamWarehouseService;
import com.zhijian.medical.util.AssertUtil;
import com.zhijian.medical.util.Page;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.util.*;

/**
 * 考核-题库业务处理层
 *
 * @author HCG
 * @date 2022-01-16 15:14:10
 * @version: 1.0
 */
@Slf4j
@Service
public class ExamWarehouseServiceImpl implements ExamWarehouseService {

    @Autowired
    private ExamWarehouseMapper mapper;

    @Autowired
    private ExamQuestionService examQuestionService;

    @Autowired
    private ExamAnswerService examAnswerService;

    /**
     * 默认题目数量
     */
    @Value("${exam.questionNum}")
    private Integer questionNum;

    @Override
    public ExamWarehouse selectById(Long id) {
        return mapper.selectByPrimaryKey(id);
    }

    @Override
    public ExamWarehouseVo selectVoById(Long id) {
        return mapper.selectVoById(id);
    }

    @Transactional(rollbackFor = Exception.class, value = "localTransactionManager")
    @Override
    public void deleteById(Long id) {
        examQuestionService.deleteByWarehouseId(id);
        examAnswerService.deleteByWarehouseId(id);
        mapper.deleteByPrimaryKey(id);
    }

    @Override
    public Long insert(ExamWarehouse examWarehouse) {
        Date now = new Date();
        examWarehouse.setCreateTime(now);
        examWarehouse.setUpdateTime(now);
        return mapper.insert(examWarehouse) == 1 ? examWarehouse.getId() : 0L;
    }

    @Override
    public boolean update(ExamWarehouse examWarehouse) {
        Date now = new Date();
        examWarehouse.setUpdateTime(now);
        return mapper.updateByPrimaryKey(examWarehouse) != 0;
    }

    @Override
    public Integer count(ExamWarehouseSearchVo examWarehouseSearchVo) {
        return mapper.count(examWarehouseSearchVo);
    }

    @Override
    public List<ExamWarehouseVo> selectList(ExamWarehouseSearchVo examWarehouseSearchVo) {
        return mapper.selectList(examWarehouseSearchVo);
    }

    @Override
    public Page<ExamWarehouseVo> selectPage(ExamWarehouseSearchVo examWarehouseSearchVo) {
        //先直接查总数
        int count = count(examWarehouseSearchVo);
        //分页
        Page<ExamWarehouseVo> page = new Page<>(true, count, examWarehouseSearchVo.getPageNum(), examWarehouseSearchVo.getPageSize());
        examWarehouseSearchVo.setStartIndex(page.getStartIndex());
        page.setPage(true);
        page.setTotalCount(count);
        List<ExamWarehouseVo> responseVos = this.selectList(examWarehouseSearchVo);
        page.setData(responseVos);
        return page;
    }

    @Transactional(rollbackFor = Exception.class, value = "localTransactionManager")
    @Override
    public boolean importExcel(Byte userType, String name, MultipartFile file) {
        InputStream inputStream = null;
        try {
            inputStream = file.getInputStream();
        } catch (IOException e) {
            e.printStackTrace();
        }
        //先保存题库
        Long examWarehouseId = this.insert(ExamWarehouse.builder()
                .userType(userType)
                .name(name)
                .build());
        ExcelReader reader = ExcelUtil.getReader(inputStream)
                .addHeaderAlias("类型", "questionType")
                .addHeaderAlias("题目", "questionContent")
                .addHeaderAlias("正确答案序号", "rightAnswerContent")
                .addHeaderAlias("选项1", "firstAnswer")
                .addHeaderAlias("选项2", "secondAnswer")
                .addHeaderAlias("选项3", "thirdAnswer")
                .addHeaderAlias("选项4", "fourthAnswer")
                .addHeaderAlias("选项5", "fifthAnswer")
                .addHeaderAlias("选项6", "sixthAnswer")
                .addHeaderAlias("选项7", "seventhAnswer")
                .addHeaderAlias("选项8", "eighth")
                .addHeaderAlias("选项8", "eighthAnswer")
                .addHeaderAlias("选项9", "ninthAnswer")
                .addHeaderAlias("选项10", "tenthAnswer")
                .addHeaderAlias("选项11", "eleventhAnswer")
                .addHeaderAlias("选项12", "twelfthAnswer")
                .addHeaderAlias("选项13", "thirteenthAnswer")
                .addHeaderAlias("选项14", "fourteenthAnswer")
                .addHeaderAlias("选项15", "fifteenthAnswer")
                .addHeaderAlias("选项16", "sixteenthAnswer")
                .addHeaderAlias("选项17", "seventeenthAnswer")
                .addHeaderAlias("选项18", "eighteenthAnswer")
                .addHeaderAlias("选项19", "nineteenthAnswer")
                .addHeaderAlias("选项20", "twentiethAnswer");
        List<ExamWarehouseImportDto> examWarehouseImportDtoList = reader.readAll(ExamWarehouseImportDto.class);
        AssertUtil.check(CollectionUtil.isEmpty(examWarehouseImportDtoList), "数据至少要有一行");
//        AssertUtil.check(CollectionUtils.isEmpty(examWarehouseImportDtoList) || examWarehouseImportDtoList.size() < questionNum, String.format("导入的题目数量小于系统最小值%d", questionNum));
        Date now = new Date();
        for (int i = 0; i < examWarehouseImportDtoList.size(); i++) {
            ExamWarehouseImportDto examWarehouseImportDto = examWarehouseImportDtoList.get(i);
            String rightAnswerContent = examWarehouseImportDto.getRightAnswerContent();
            if (StringUtils.isBlank(examWarehouseImportDto.getQuestionType())
                    || StringUtils.isBlank(examWarehouseImportDto.getQuestionContent())
                    || StringUtils.isBlank(rightAnswerContent)
                    || StringUtils.isBlank(examWarehouseImportDto.getFirstAnswer())
                    || StringUtils.isBlank(examWarehouseImportDto.getSecondAnswer())
                    || StringUtils.isBlank(examWarehouseImportDto.getThirdAnswer())
                    || StringUtils.isBlank(examWarehouseImportDto.getFourthAnswer())) {
                throw new BusinessException(ResponseCodeEnum.FAILURE.code, String.format("第%s行有空数据，请重新填写", i + 1));
            }
            QuestionTypeEnum questionTypeEnum = QuestionTypeEnum.getByType(examWarehouseImportDto.getQuestionType());
            if (Objects.isNull(questionTypeEnum)) {
                //非法的类型
                throw new BusinessException(ResponseCodeEnum.FAILURE.code, String.format("第%s行类型非法，请重新填写", i + 1));
            }
            if (!questionTypeEnum.equals(QuestionTypeEnum.SINGLE_SELECTION) && !questionTypeEnum.equals(QuestionTypeEnum.MULTIPLE_SELECTION)) {
                //todo
                throw new BusinessException(ResponseCodeEnum.FAILURE.code, "目前仅支持单选题与多选题");
            }
            //是否是单选题，否的话那就是多选题
            boolean isSingle = questionTypeEnum.equals(QuestionTypeEnum.SINGLE_SELECTION);
            //正确答案，分割后
            List<String> rightAnswerContentList = Arrays.asList(rightAnswerContent.split(","));

            //保存问题
            Long questionId = examQuestionService.insert(ExamQuestion.builder()
                    .warehouseId(examWarehouseId)
                    .content(examWarehouseImportDto.getQuestionContent())
                    .type(questionTypeEnum.getCode().byteValue())
                    .build());
            //保存20个选项
            List<ExamAnswer> examAnswerList = Lists.newArrayList();
            examAnswerList.add(ExamAnswer.builder()
                    .questionId(questionId)
                    .content(examWarehouseImportDto.getFirstAnswer())
                    .weatherRight(rightAnswerContentList.contains("1") ? (byte) 0 : 1)
                    .warehouseId(examWarehouseId)
                    .createTime(now)
                    .updateTime(now)
                    .build());

            examAnswerList.add(ExamAnswer.builder()
                    .questionId(questionId)
                    .content(examWarehouseImportDto.getSecondAnswer())
                    .weatherRight(rightAnswerContentList.contains("2") ? (byte) 0 : 1)
                    .warehouseId(examWarehouseId)
                    .createTime(now)
                    .updateTime(now)
                    .build());

            examAnswerList.add(ExamAnswer.builder()
                    .questionId(questionId)
                    .content(examWarehouseImportDto.getThirdAnswer())
                    .weatherRight(rightAnswerContentList.contains("3") ? (byte) 0 : 1)
                    .warehouseId(examWarehouseId)
                    .createTime(now)
                    .updateTime(now)
                    .build());

            examAnswerList.add(ExamAnswer.builder()
                    .questionId(questionId)
                    .content(examWarehouseImportDto.getFourthAnswer())
                    .weatherRight(rightAnswerContentList.contains("4") ? (byte) 0 : 1)
                    .warehouseId(examWarehouseId)
                    .createTime(now)
                    .updateTime(now)
                    .build());

            //第五
            if (StringUtils.isNotBlank(examWarehouseImportDto.getFifthAnswer())) {
                examAnswerList.add(ExamAnswer.builder()
                        .questionId(questionId)
                        .content(examWarehouseImportDto.getFifthAnswer())
                        .weatherRight(rightAnswerContentList.contains("5") ? (byte) 0 : 1)
                        .warehouseId(examWarehouseId)
                        .createTime(now)
                        .updateTime(now)
                        .build());
            } else {
                examAnswerService.insertBatch(examAnswerList);
                continue;
            }

            //第六
            if (StringUtils.isNotBlank(examWarehouseImportDto.getSixthAnswer())) {
                examAnswerList.add(ExamAnswer.builder()
                        .questionId(questionId)
                        .content(examWarehouseImportDto.getSixthAnswer())
                        .weatherRight(rightAnswerContentList.contains("6") ? (byte) 0 : 1)
                        .warehouseId(examWarehouseId)
                        .createTime(now)
                        .updateTime(now)
                        .build());
            } else {
                examAnswerService.insertBatch(examAnswerList);
                continue;
            }

            //第七
            if (StringUtils.isNotBlank(examWarehouseImportDto.getSeventhAnswer())) {
                examAnswerList.add(ExamAnswer.builder()
                        .questionId(questionId)
                        .content(examWarehouseImportDto.getSeventhAnswer())
                        .weatherRight(rightAnswerContentList.contains("7") ? (byte) 0 : 1)
                        .warehouseId(examWarehouseId)
                        .createTime(now)
                        .updateTime(now)
                        .build());
            } else {
                examAnswerService.insertBatch(examAnswerList);
                continue;
            }

            //第八
            if (StringUtils.isNotBlank(examWarehouseImportDto.getEighthAnswer())) {
                examAnswerList.add(ExamAnswer.builder()
                        .questionId(questionId)
                        .content(examWarehouseImportDto.getEighthAnswer())
                        .weatherRight(rightAnswerContentList.contains("8") ? (byte) 0 : 1)
                        .warehouseId(examWarehouseId)
                        .createTime(now)
                        .updateTime(now)
                        .build());
            } else {
                examAnswerService.insertBatch(examAnswerList);
                continue;
            }

            //第九
            if (StringUtils.isNotBlank(examWarehouseImportDto.getNinthAnswer())) {
                examAnswerList.add(ExamAnswer.builder()
                        .questionId(questionId)
                        .content(examWarehouseImportDto.getNinthAnswer())
                        .weatherRight(rightAnswerContentList.contains("9") ? (byte) 0 : 1)
                        .warehouseId(examWarehouseId)
                        .createTime(now)
                        .updateTime(now)
                        .build());
            } else {
                examAnswerService.insertBatch(examAnswerList);
                continue;
            }

            //第10
            if (StringUtils.isNotBlank(examWarehouseImportDto.getTenthAnswer())) {
                examAnswerList.add(ExamAnswer.builder()
                        .questionId(questionId)
                        .content(examWarehouseImportDto.getTenthAnswer())
                        .weatherRight(rightAnswerContentList.contains("10") ? (byte) 0 : 1)
                        .warehouseId(examWarehouseId)
                        .createTime(now)
                        .updateTime(now)
                        .build());
            } else {
                examAnswerService.insertBatch(examAnswerList);
                continue;
            }

            //第11
            if (StringUtils.isNotBlank(examWarehouseImportDto.getEleventhAnswer())) {
                examAnswerList.add(ExamAnswer.builder()
                        .questionId(questionId)
                        .content(examWarehouseImportDto.getEleventhAnswer())
                        .weatherRight(rightAnswerContentList.contains("11") ? (byte) 0 : 1)
                        .warehouseId(examWarehouseId)
                        .createTime(now)
                        .updateTime(now)
                        .build());
            } else {
                examAnswerService.insertBatch(examAnswerList);
                continue;
            }

            //第12
            if (StringUtils.isNotBlank(examWarehouseImportDto.getTwelfthAnswer())) {
                examAnswerList.add(ExamAnswer.builder()
                        .questionId(questionId)
                        .content(examWarehouseImportDto.getTwelfthAnswer())
                        .weatherRight(rightAnswerContentList.contains("12") ? (byte) 0 : 1)
                        .warehouseId(examWarehouseId)
                        .createTime(now)
                        .updateTime(now)
                        .build());
            } else {
                examAnswerService.insertBatch(examAnswerList);
                continue;
            }

            //第13
            if (StringUtils.isNotBlank(examWarehouseImportDto.getThirteenthAnswer())) {
                examAnswerList.add(ExamAnswer.builder()
                        .questionId(questionId)
                        .content(examWarehouseImportDto.getThirteenthAnswer())
                        .weatherRight(rightAnswerContentList.contains("13") ? (byte) 0 : 1)
                        .warehouseId(examWarehouseId)
                        .createTime(now)
                        .updateTime(now)
                        .build());
            } else {
                examAnswerService.insertBatch(examAnswerList);
                continue;
            }

            //第14
            if (StringUtils.isNotBlank(examWarehouseImportDto.getFourteenthAnswer())) {
                examAnswerList.add(ExamAnswer.builder()
                        .questionId(questionId)
                        .content(examWarehouseImportDto.getFourteenthAnswer())
                        .weatherRight(rightAnswerContentList.contains("14") ? (byte) 0 : 1)
                        .warehouseId(examWarehouseId)
                        .createTime(now)
                        .updateTime(now)
                        .build());
            } else {
                examAnswerService.insertBatch(examAnswerList);
                continue;
            }

            //第15
            if (StringUtils.isNotBlank(examWarehouseImportDto.getFifteenthAnswer())) {
                examAnswerList.add(ExamAnswer.builder()
                        .questionId(questionId)
                        .content(examWarehouseImportDto.getFifteenthAnswer())
                        .weatherRight(rightAnswerContentList.contains("15") ? (byte) 0 : 1)
                        .warehouseId(examWarehouseId)
                        .createTime(now)
                        .updateTime(now)
                        .build());
            } else {
                examAnswerService.insertBatch(examAnswerList);
                continue;
            }

            //第16
            if (StringUtils.isNotBlank(examWarehouseImportDto.getSixteenthAnswer())) {
                examAnswerList.add(ExamAnswer.builder()
                        .questionId(questionId)
                        .content(examWarehouseImportDto.getSixteenthAnswer())
                        .weatherRight(rightAnswerContentList.contains("16") ? (byte) 0 : 1)
                        .warehouseId(examWarehouseId)
                        .createTime(now)
                        .updateTime(now)
                        .build());
            } else {
                examAnswerService.insertBatch(examAnswerList);
                continue;
            }

            //第17
            if (StringUtils.isNotBlank(examWarehouseImportDto.getSeventeenthAnswer())) {
                examAnswerList.add(ExamAnswer.builder()
                        .questionId(questionId)
                        .content(examWarehouseImportDto.getSeventeenthAnswer())
                        .weatherRight(rightAnswerContentList.contains("17") ? (byte) 0 : 1)
                        .warehouseId(examWarehouseId)
                        .createTime(now)
                        .updateTime(now)
                        .build());
            } else {
                examAnswerService.insertBatch(examAnswerList);
                continue;
            }

            //第18
            if (StringUtils.isNotBlank(examWarehouseImportDto.getEighteenthAnswer())) {
                examAnswerList.add(ExamAnswer.builder()
                        .questionId(questionId)
                        .content(examWarehouseImportDto.getEighteenthAnswer())
                        .weatherRight(rightAnswerContentList.contains("18") ? (byte) 0 : 1)
                        .warehouseId(examWarehouseId)
                        .createTime(now)
                        .updateTime(now)
                        .build());
            } else {
                examAnswerService.insertBatch(examAnswerList);
                continue;
            }

            //第19
            if (StringUtils.isNotBlank(examWarehouseImportDto.getNineteenthAnswer())) {
                examAnswerList.add(ExamAnswer.builder()
                        .questionId(questionId)
                        .content(examWarehouseImportDto.getNineteenthAnswer())
                        .weatherRight(rightAnswerContentList.contains("19") ? (byte) 0 : 1)
                        .warehouseId(examWarehouseId)
                        .createTime(now)
                        .updateTime(now)
                        .build());
            } else {
                examAnswerService.insertBatch(examAnswerList);
                continue;
            }

            //第20
            if (StringUtils.isNotBlank(examWarehouseImportDto.getTwentiethAnswer())) {
                examAnswerList.add(ExamAnswer.builder()
                        .questionId(questionId)
                        .content(examWarehouseImportDto.getTwentiethAnswer())
                        .weatherRight(rightAnswerContentList.contains("20") ? (byte) 0 : 1)
                        .warehouseId(examWarehouseId)
                        .createTime(now)
                        .updateTime(now)
                        .build());
            }
            examAnswerService.insertBatch(examAnswerList);

        }
        return true;
    }

    @Override
    public void export(Long id, HttpServletResponse response) {
        List<ExamWarehouseImportDto> examWarehouseImportDtoList = this.selectImportDtoListById(id);
        ExcelWriter writer = ExcelUtil.getWriter(true);

        writer.addHeaderAlias("questionType", "类型")
                .addHeaderAlias("questionContent", "题目")
                .addHeaderAlias("rightAnswerContent", "正确答案")
                .addHeaderAlias("firstAnswer", "选项1")
                .addHeaderAlias("secondAnswer", "选项2")
                .addHeaderAlias("thirdAnswer", "选项3")
                .addHeaderAlias("fourthAnswer", "选项4")
                .addHeaderAlias("fifthAnswer", "选项5")
                .addHeaderAlias("sixthAnswer", "选项6")
                .addHeaderAlias("seventhAnswer", "选项7")
                .addHeaderAlias("eighthAnswer", "选项8")
                .addHeaderAlias("ninthAnswer", "选项9")
                .addHeaderAlias("tenthAnswer", "选项10")
                .addHeaderAlias("eleventhAnswer", "选项11")
                .addHeaderAlias("twelfthAnswer", "选项12")
                .addHeaderAlias("thirteenthAnswer", "选项13")
                .addHeaderAlias("fourteenthAnswer", "选项14")
                .addHeaderAlias("fifteenthAnswer", "选项15")
                .addHeaderAlias("sixteenthAnswer", "选项16")
                .addHeaderAlias("seventeenthAnswer", "选项17")
                .addHeaderAlias("eighteenthAnswer", "选项18")
                .addHeaderAlias("nineteenthAnswer", "选项19")
                .addHeaderAlias("twentiethAnswer", "选项20")
        ;
        // 合并单元格后的标题行，使用默认标题样式
        writer.merge(6, "题库记录");
        // 默认的，未添加alias的属性也会写出，如果想只写出加了别名的字段，可以调用此方法排除之
        writer.setOnlyAlias(true);
        writer.setColumnWidth(-1, 30);
        writer.write(examWarehouseImportDtoList, true);

        response.setContentType("application/vnd.ms-excel");
        response.setHeader("Content-Disposition", String.format("attachment;filename=%s.xlsx", "题库记录"));
        ServletOutputStream out = null;
        try {
            out = response.getOutputStream();
            writer.flush(out, true);
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            writer.close();
            IoUtil.close(out);
        }
    }

    @Override
    public List<ExamWarehouseImportDto> selectImportDtoListById(Long id) {
        List<ExamQuestionVo> examQuestionVos = examQuestionService.selectList(ExamQuestionSearchVo.builder()
                .warehouseId(id)
                .build());
        List<ExamWarehouseImportDto> examWarehouseImportDtoList = new LinkedList<>();
        examQuestionVos.forEach(examQuestionVo -> {
            List<ExamAnswerVo> examAnswerVos = examAnswerService.selectList(ExamAnswerSearchVo.builder()
                    .questionId(examQuestionVo.getId())
                    .build());
            if (!CollectionUtils.isEmpty(examAnswerVos)) {
                ExamWarehouseImportDto examWarehouseImportDto = new ExamWarehouseImportDto();
                //题目类型
                QuestionTypeEnum questionTypeEnum = QuestionTypeEnum.getByCode(Integer.valueOf(examQuestionVo.getType()));
                if (Objects.nonNull(questionTypeEnum)) {
                    examWarehouseImportDto.setQuestionType(questionTypeEnum.getType());
                }
                //题目内容
                examWarehouseImportDto.setQuestionContent(examQuestionVo.getContent());
                //默认取20个选项
                List<String> rightAnwerList = Lists.newLinkedList();
                for (int i = 0; i < examAnswerVos.size() || i < 20; i++) {
                    if (i == 0) {
                        //选项1
                        ExamAnswerVo examAnswerVo = examAnswerVos.get(0);
                        examWarehouseImportDto.setFirstAnswer(examAnswerVo.getContent());
                        if (examAnswerVo.getWeatherRight() == 0) {
                            rightAnwerList.add("1");
                        }
                    } else if (examAnswerVos.size() > 1 && i == 1) {
                        //选项2
                        ExamAnswerVo examAnswerVo = examAnswerVos.get(1);
                        examWarehouseImportDto.setSecondAnswer(examAnswerVo.getContent());
                        if (examAnswerVo.getWeatherRight() == 0) {
                            rightAnwerList.add("2");
                        }
                    } else if (examAnswerVos.size() > 2 && i == 2) {
                        //选项3
                        ExamAnswerVo examAnswerVo = examAnswerVos.get(2);
                        examWarehouseImportDto.setThirdAnswer(examAnswerVo.getContent());
                        if (examAnswerVo.getWeatherRight() == 0) {
                            rightAnwerList.add("3");
                        }
                    } else if (examAnswerVos.size() > 3 && i == 3) {
                        //选项4
                        ExamAnswerVo examAnswerVo = examAnswerVos.get(3);
                        examWarehouseImportDto.setFourthAnswer(examAnswerVo.getContent());
                        if (examAnswerVo.getWeatherRight() == 0) {
                            rightAnwerList.add("4");
                        }
                    } else if (examAnswerVos.size() > 4 && i == 4) {
                        //选项5
                        ExamAnswerVo examAnswerVo = examAnswerVos.get(4);
                        examWarehouseImportDto.setFifthAnswer(examAnswerVo.getContent());
                        if (examAnswerVo.getWeatherRight() == 0) {
                            rightAnwerList.add("5");
                        }
                    } else if (examAnswerVos.size() > 5 && i == 5) {
                        //选项6
                        ExamAnswerVo examAnswerVo = examAnswerVos.get(5);
                        examWarehouseImportDto.setSixthAnswer(examAnswerVo.getContent());
                        if (examAnswerVo.getWeatherRight() == 0) {
                            rightAnwerList.add("6");
                        }
                    } else if (examAnswerVos.size() > 6 && i == 6) {
                        //选项7
                        ExamAnswerVo examAnswerVo = examAnswerVos.get(6);
                        examWarehouseImportDto.setSeventhAnswer(examAnswerVo.getContent());
                        if (examAnswerVo.getWeatherRight() == 0) {
                            rightAnwerList.add("7");
                        }
                    } else if (examAnswerVos.size() > 7 && i == 7) {
                        //选项8
                        ExamAnswerVo examAnswerVo = examAnswerVos.get(7);
                        examWarehouseImportDto.setEighthAnswer(examAnswerVo.getContent());
                        if (examAnswerVo.getWeatherRight() == 0) {
                            rightAnwerList.add("8");
                        }
                    } else if (examAnswerVos.size() > 8 && i == 8) {
                        //选项9
                        ExamAnswerVo examAnswerVo = examAnswerVos.get(8);
                        examWarehouseImportDto.setNinthAnswer(examAnswerVo.getContent());
                        if (examAnswerVo.getWeatherRight() == 0) {
                            rightAnwerList.add("9");
                        }
                    } else if (examAnswerVos.size() > 9 && i == 9) {
                        //选项10
                        ExamAnswerVo examAnswerVo = examAnswerVos.get(9);
                        examWarehouseImportDto.setTenthAnswer(examAnswerVo.getContent());
                        if (examAnswerVo.getWeatherRight() == 0) {
                            rightAnwerList.add("10");
                        }
                    } else if (examAnswerVos.size() > 10 && i == 10) {
                        //选项11
                        ExamAnswerVo examAnswerVo = examAnswerVos.get(10);
                        examWarehouseImportDto.setEleventhAnswer(examAnswerVo.getContent());
                        if (examAnswerVo.getWeatherRight() == 0) {
                            rightAnwerList.add("11");
                        }
                    } else if (examAnswerVos.size() > 11 && i == 11) {
                        //选项12
                        ExamAnswerVo examAnswerVo = examAnswerVos.get(11);
                        examWarehouseImportDto.setTwelfthAnswer(examAnswerVo.getContent());
                        if (examAnswerVo.getWeatherRight() == 0) {
                            rightAnwerList.add("12");
                        }
                    } else if (examAnswerVos.size() > 12 && i == 12) {
                        //选项13
                        ExamAnswerVo examAnswerVo = examAnswerVos.get(12);
                        examWarehouseImportDto.setThirteenthAnswer(examAnswerVo.getContent());
                        if (examAnswerVo.getWeatherRight() == 0) {
                            rightAnwerList.add("13");
                        }
                    } else if (examAnswerVos.size() > 13 && i == 13) {
                        //选项14
                        ExamAnswerVo examAnswerVo = examAnswerVos.get(13);
                        examWarehouseImportDto.setFourteenthAnswer(examAnswerVo.getContent());
                        if (examAnswerVo.getWeatherRight() == 0) {
                            rightAnwerList.add("14");
                        }
                    } else if (examAnswerVos.size() > 14 && i == 14) {
                        //选项15
                        ExamAnswerVo examAnswerVo = examAnswerVos.get(14);
                        examWarehouseImportDto.setFifteenthAnswer(examAnswerVo.getContent());
                        if (examAnswerVo.getWeatherRight() == 0) {
                            rightAnwerList.add("15");
                        }
                    } else if (examAnswerVos.size() > 15 && i == 15) {
                        //选项16
                        ExamAnswerVo examAnswerVo = examAnswerVos.get(15);
                        examWarehouseImportDto.setSixteenthAnswer(examAnswerVo.getContent());
                        if (examAnswerVo.getWeatherRight() == 0) {
                            rightAnwerList.add("16");
                        }
                    } else if (examAnswerVos.size() > 16 && i == 16) {
                        //选项17
                        ExamAnswerVo examAnswerVo = examAnswerVos.get(16);
                        examWarehouseImportDto.setSeventeenthAnswer(examAnswerVo.getContent());
                        if (examAnswerVo.getWeatherRight() == 0) {
                            rightAnwerList.add("17");
                        }
                    } else if (examAnswerVos.size() > 17 && i == 17) {
                        //选项18
                        ExamAnswerVo examAnswerVo = examAnswerVos.get(17);
                        examWarehouseImportDto.setEighteenthAnswer(examAnswerVo.getContent());
                        if (examAnswerVo.getWeatherRight() == 0) {
                            rightAnwerList.add("18");
                        }
                    } else if (examAnswerVos.size() > 18 && i == 18) {
                        //选项19
                        ExamAnswerVo examAnswerVo = examAnswerVos.get(18);
                        examWarehouseImportDto.setNineteenthAnswer(examAnswerVo.getContent());
                        if (examAnswerVo.getWeatherRight() == 0) {
                            rightAnwerList.add("19");
                        }
                    } else if (examAnswerVos.size() > 19 && i == 19) {
                        //选项20
                        ExamAnswerVo examAnswerVo = examAnswerVos.get(19);
                        examWarehouseImportDto.setTwentiethAnswer(examAnswerVo.getContent());
                        if (examAnswerVo.getWeatherRight() == 0) {
                            rightAnwerList.add("20");
                        }
                    }
                    if (CollectionUtil.isNotEmpty(rightAnwerList)) {
                        examWarehouseImportDto.setRightAnswerContent(String.join(",", rightAnwerList));
                    }
                }
                examWarehouseImportDtoList.add(examWarehouseImportDto);
            }

        });
        return examWarehouseImportDtoList;
    }

}